package com.demo.java.OD301_350.OD314;

import java.util.Scanner;

/**
 * @author bug菌
 * @Source 公众号：猿圈奇妙屋
 * @des： 【出错的或电路(B卷)】问题
 * @url： https://blog.csdn.net/weixin_43970743/article/details/146105799
 */
public class OdMain {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 读取长度
        int length = scanner.nextInt();
        scanner.nextLine(); // 跳过输入换行符

        // 读取两个二进制字符串
        String string1 = scanner.nextLine();
        String string2 = scanner.nextLine();

        // 统计string1中'1'的个数
        int count1 = countOccurrences(string1, "1");
        // 统计string2中'0'的个数
        int count0 = countOccurrences(string2, "0");
        // 统计string1中'1'与string2中'0'的配对次数
        int count01 = count01Occurrences(length, string1, string2);

        // 计算最终结果
        int result = (count1 - count01) * (count0 - count01) + (length - count1) * count01;
        System.out.println(result);

        scanner.close();
    }

    // 统计字符串中某个字符出现的次数
    private static int countOccurrences(String str, String target) {
        int count = 0;
        int index = 0;
        // 使用indexOf方法查找字符串中的目标字符
        while ((index = str.indexOf(target, index)) != -1) {
            count++;
            index += target.length();
        }
        return count;
    }

    // 统计'1'和'0'在两条字符串中匹配的次数
    private static int count01Occurrences(int length, String str1, String str2) {
        int count = 0;
        for (int i = 0; i < length; i++) {
            if (str2.charAt(i) == '0' && str1.charAt(i) == '1') {
                count++;
            }
        }
        return count;
    }
}